<h2>DESCRIPTION</h2>

<em>m.cogo</em> converts data points between bearing and distance
and X,Y coordinates.  Only simple bearing/distance or coordinate
pairs are handled. It assumes a cartesian coordinate system.

<p>
Input can be entered via standard input (default) or from the file
<b>input=</b><em>name</em>. Specifying the input as "-" also
specifies standard input, and is useful for using the program in
a pipeline.  Output will be to standard output unless a file
name other than "-" is specified.  The input file must
closely adhere to the following format, where up to a 10 character
label is allowed but not required (see <b>-l</b> flag).

<p>
<b>Example COGO input:</b>
<div class="code"><pre>
   P23 N 23:14:12 W 340
   P24 S 04:18:56 E 230
   ...
</pre></div>

<p>
The first column may contain a label and you must use the <b>-l</b>
flag so the program knows.  This is followed by a space, and then
either the character 'N' or 'S' to indicate whether the bearing is
relative to the north or south directions.  After another space,
the angle begins in degrees, minutes, and seconds in
"DDD:MM:SS.SSSS" format. Generally, the angle can be of the form
<em>digits + separator + digits + separator + digits [+ '.' + digits]</em>.
A space follows the angle, and is then followed by either the 'E' or 'W'
characters. A space separates the bearing from the distance (which should
be in appropriate linear units).

<p>
<b>Output of the above input:</b>
<div class="code"><pre>
   -134.140211 312.420236 P23
   -116.832837 83.072345 P24
   ...
</pre></div>

<p>
Unless specified with the <b>coord</b> option, calculations begin from (0,0).


<h2>NOTES</h2>

For those unfamiliar with the notation for bearings: Picture yourself in the
center of a circle.  The first hemispere notation tell you whether you should
face north or south.  Then you read the angle and either turn that many
degrees to the east or west, depending on the second hemisphere notation.  
Finally, you move &lt;distance&gt; units in that direction to get to the 
next station.

<p>
<em>m.cogo</em> can be run either non-interactively or
interactively.  The program will be run non-interactively
if the user specifies any parameter or flag. Use "m.cogo -",
to run the program in a pipeline.  Without any flags or
parameters, <em>m.cogo</em> will prompt for each value
using the familiar GRASS parser interface.

<p>
This program is very simplistic, and will not handle deviations
from the input format explained above.  Currently, the
program doesn't do anything particularly useful with
the output.  However, it is envisioned that this program
will be extended to provide the capability to generate
vector and/or sites layers.

<p>
Lines may be closed by using the <b>-c</b> flag or snapped with
<em>v.clean</em>, lines may be converted to boundaries with <em>v.type</em>,
and closed boundaries may be converted to areas with <em>v.centroids</em>.


<h2>EXAMPLES</h2>

<div class="code"><pre>
   m.cogo -l in=cogo.dat
</pre></div>

Where the <tt>cogo.dat</tt> input file looks like:
<div class="code"><pre>
# Sample COGO input file -- This defines an area.
# &lt;label&gt; &lt;bearing&gt; &lt;distance&gt;
P001 S 88:44:56 W 6.7195
P002 N 33:34:15 W 2.25
P003 N 23:23:50 W 31.4024
P004 N 05:04:45 W 25.6981
P005 N 18:07:25 E 22.2439
P006 N 27:49:50 E 75.7317
P007 N 22:56:50 E 87.4482
P008 N 37:45:15 E 37.7835
P009 N 46:04:30 E 11.5854
P010 N 90:00:00 E 8.8201
P011 N 90:00:00 E 164.1128
P012 S 48:41:12 E 10.1311
P013 S 00:25:50 W 255.7652
P014 N 88:03:13 W 98.8567
P015 S 88:44:56 W 146.2713
P016 S 88:44:56 W 18.7164
</pre></div>

<p>
Round trip:
<div class="code"><pre>
   m.cogo -l input=cogo.dat | m.cogo -rl in="-"
</pre></div>

<p>
Import as a vector points map:
<div class="code"><pre>
   m.cogo -l input=cogo.dat | v.in.ascii output=cogo_points x=1 y=2 separator=space
</pre></div>

<p>
Shell script to import as a vector line map:
<div class="code"><pre>
   m.cogo -l input=cogo.dat | tac | awk '
       BEGIN { FS=" " ; R=0 }
       $1~/\d*\.\d*/ { printf(" %.8f %.8f\n", $1, $2) ; ++R }
       END { printf("L %d\n", R) }' | tac | \
       v.in.ascii -n format=standard out=cogo_line
</pre></div>

<p>
Convert that lines map into an area:
<div class="code"><pre>
   # Add the -c flag to the above example to close the loop:
   m.cogo -l -c input=cogo.dat | ...
       ...
   v.type input=cogo_line output=cogo_boundary from_type=line to_type=boundary
   v.centroids input=cogo_boundary output=cogo_area
</pre></div>

If necessary, snap the boundary closed with the <em>v.clean</em> module.
Use <tt>tool=snap</tt> and <tt>thresh=0.0001</tt>, or some small value.
<!-- does that need a cat number on the boundary to work? -->


<h2>SEE ALSO</h2>

<em>
<a href="v.centroids.html">v.centroids</a>,
<a href="v.clean.html">v.clean</a>,
<a href="wxGUI.vdigit.html">wxGUI vector digitizer</a>,
<a href="v.in.ascii.html">v.in.ascii</a>,
<a href="v.type.html">v.type</a>
</em>


<h2>AUTHOR</h2>

Eric G. Miller

<!--
<p>
<i>Last changed: $Date$</i>
-->
